Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Allows users to pass a custom DateTimeFormatter for the ZonedDateTime… #44

Merged
merged 1 commit into from
Oct 2, 2015

Conversation

tinnou
Copy link

@tinnou tinnou commented Oct 2, 2015

…Serializer

@cowtowncoder
Copy link
Member

Sounds reasonable, would be happy to merge.

Before merging the contribution, the one thing we need is a filled Contributor License Agreement (CLA), from https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf
so if it would be possible to print it, fill & sign, scan and email to info at fasterxml dot com, that'd be great.

Looking forward to merging this fix.

@tinnou
Copy link
Author

tinnou commented Oct 2, 2015

Cool. Sent.

@cowtowncoder
Copy link
Member

I will actually merge this to be included in 2.6.3 just because I haven't upgraded master yet -- so it will be included before 2.7. Just as an FYI; officially API shouldn't change in patch versions, but this is safe enough so as not to cause issues.

cowtowncoder added a commit that referenced this pull request Oct 2, 2015
Allows users to pass a custom DateTimeFormatter for the ZonedDateTime…
@cowtowncoder cowtowncoder merged commit f827d43 into FasterXML:master Oct 2, 2015
@cowtowncoder cowtowncoder added this to the 2.6.3 milestone Oct 2, 2015
@cbornet
Copy link

cbornet commented Sep 1, 2016

Would be great to also be able to do that with OffsetDateTime !

@cowtowncoder
Copy link
Member

PRs welcome!

@cbornet
Copy link

cbornet commented Sep 1, 2016

Yes. I'll see if I have time.
It should also be possible to easily format Instant. Then there could be a method in JavaTimeModule to set the format and timezone of all Instant based types at once.

@cowtowncoder
Copy link
Member

@cbornet Actually there already is general-purpose support, as of 2.8:

JsonFormat.Value format = ....;
mapper.configOverride(Instance.class).setFormat(format);

as long as Instance (de)serializer accepts @JsonFormat information via createContextual().

@cbornet
Copy link

cbornet commented Sep 1, 2016

Yes but you need to do this for Instant, ZonedDateTime, OffsetDateTime. It would be useful to have something like setInstantBasedTypeFormatter(DateTimeFormatter format). I don't think it can be done on the mapper since it belongs to the core so I'm wondering if it couldn't be done on the JavaTimeModule.

@cowtowncoder
Copy link
Member

@cbornet It is a general facility to use and superior in that sense. But I could see benefit of having a helper method in JavaTimeModule that could act as shortcut like you suggest; method to call before registering.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants